Fix MATCH_SET parsing of quoted items and add tests#13024
Fix MATCH_SET parsing of quoted items and add tests#13024cmcfarlen merged 3 commits intoapache:masterfrom
Conversation
The set parser was incorrectly advancing 'start' by skip_quotes after a comma, causing the second and subsequent quoted items to be parsed with their leading characters truncated. Add a unit test for quoted set parsing and enable the test_matcher build target (fix linker issue by removing resources.cc and adding stubs). Add autest coverage for quoted sets in header_rewrite bundle. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Fixes MATCH_SET parsing in the header_rewrite plugin so quoted list items after the first element aren’t truncated, and adds regression coverage in both unit tests and gold tests.
Changes:
- Adjust
MATCH_SETparsing cursor advancement for quoted items. - Add Catch2 unit test coverage for quoted set parsing.
- Add gold test rules and replay transactions to validate quoted set matching behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/gold_tests/pluginTest/header_rewrite/rules/rule_client.conf | Adds a new rule to exercise quoted set matching in SEND_RESPONSE_HDR_HOOK. |
| tests/gold_tests/pluginTest/header_rewrite/header_rewrite_bundle.replay.yaml | Adds two replay transactions validating quoted set match/non-match behavior. |
| plugins/header_rewrite/matcher_tests.cc | Adds stubs to make matcher tests linkable without full resources implementation and adds a quoted set unit test. |
| plugins/header_rewrite/matcher.h | Changes MATCH_SET parsing to avoid truncating subsequent quoted items. |
| plugins/header_rewrite/CMakeLists.txt | Adjusts (commented) test_matcher target lines and linker notes/handling. |
| headers: | ||
| fields: | ||
| - [ Host, www.example.com ] | ||
| - [ X-Quoted-Set, "bar" ] |
There was a problem hiding this comment.
Is "bar" really quoted by the time this traffic is replayed? I think yaml will just see the quotes and understand this as a string type, right?
Might need to escape the quotes:
- [ X-Quoted-Set, "\"bar\"" ]There was a problem hiding this comment.
The quotes are on the hrw side. The header side are not expected to be quotes. These extra checks are to test that values past the first on match.
There was a problem hiding this comment.
I see. The comment at line 317 threw me off. I thought this needed to test Proxy Verifier handing down literal quoted strings.
|
Cherry-picked to 10.2.x |
* Fix MATCH_SET parsing of quoted items and add tests The set parser was incorrectly advancing 'start' by skip_quotes after a comma, causing the second and subsequent quoted items to be parsed with their leading characters truncated. Add a unit test for quoted set parsing and enable the test_matcher build target (fix linker issue by removing resources.cc and adding stubs). Add autest coverage for quoted sets in header_rewrite bundle. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * link cripts to test if enabled * nevermind, that test is cursed --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> (cherry picked from commit 52688fe)
The set parser was incorrectly advancing 'start' by skip_quotes after a comma, causing the second and subsequent quoted items to be parsed with their leading characters truncated.
Add a unit test for quoted set parsing and enable the test_matcher build target (fix linker issue by removing resources.cc and adding stubs). Add autest coverage for quoted sets in header_rewrite bundle.